<?php
	
	namespace app\api\controller;
	
	use app\common\controller\Api;
	use think\Db;
	
	class Sensitive extends Api
	{
		
		protected $noNeedLogin = [];
		protected $noNeedRight = ['*'];
		
		public function Index(){}
		
		public function Words()
		{
			
			if (!$this->request->isGet()){
				$this->error('请求方法不允许', null, 405);
			}
			
			$this->request->filter(['strip_tags', 'trim']);
			
			// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
			
			$list = Db::name("sensitive_words")->field('id, cid, words, level')
				->where([])
				->paginate(10);
			// foreach ($list as $k => $v) {
			// 	$v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname);
			// 	$v->hidden(['password', 'salt']);
			// }
			$result = array("total" => $list->total(), "rows" => $list->items());
			
			$this->success('敏感词列表', $result);
			
		}
		
		
		
		public function Category()
		{
			if (!$this->request->isGet()){
				$this->error('请求方法不允许', null, 405);
			}
			
			
			$this->request->filter(['strip_tags', 'trim']);
			
			// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
			$list = Db::name("sensitive_words_category")->field('id, cate_name')
			          ->where([])
			          ->paginate(10);
			// foreach ($list as $k => $v) {
			// 	$v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname);
			// 	$v->hidden(['password', 'salt']);
			// }
			$result = array("total" => $list->total(), "rows" => $list->items());
			
			$this->success('敏感词分类列表', $result);
		}
		
		
	}
